/*
 * Copyrights of MYeBills. Do not copy or distribute without permissions.
 *
 * TODO 
 */
package com.mbbmap.app.dao;

import org.owasp.encoder.Encode;
import java.util.ArrayList;
/**
 * @author Lue
 *
 * Payee User Role data structure
 */
public class UserRoleDao {

    String roleId, roleName;
    
    public UserRoleDao(String roleId, String roleName) {
        this.roleId = roleId;
        this.roleName = roleName;
    }
    
    public UserRoleDao() {
        
    }
    
    public void setRoleId (String roleId) {
        this.roleId = roleId;
    }
    
    public void setRoleName (String roleName) {
        this.roleName = roleName;
    }
    
    
    // GETTER
    
    public String getRoleId () {
        return Encode.forHtml(roleId);
    }
    
    public String getRoleName () {
        return Encode.forHtml(roleName);
    }
    
    /**
     * Get role name for the given role ID from the ArrayList of roles
     * @param roleId
     * @param roles
     * @return
     */
    public static String getRole(String roleId, ArrayList roles) {
        UserRoleDao role;
        String roleName=null;
        for (int i=0; i < roles.size(); i++) {
            role = (UserRoleDao) roles.get(i);
            
            if (role.getRoleId().equals(roleId)) {
                roleName = role.getRoleName();
                break;
            }
        }
        
        return roleName;
        
    }

}
